$(function() {
	function b(a) {
		next("unnow", "unsuccess");
		fresh_pages()
	}
	function d(a) {
		comfirmBtn("#now-sure");
		layer.msg(a.errorMsg, {
			icon: 0,
			time: 2E3,
			offset: 300
		})
	}
	function e(a) {
		next("four-bind", "unpaybind");
		fresh_pages();
		clearForm()
	}
	function f(a) {
		layer.msg(a.errorMsg, {
			icon: 0,
			time: 2E3,
			offset: 300
		})
	}
	function g(a) {
		next("nowmail", "successmail");
		fresh_pages()
	}
	function h(a) {
		comfirmBtn("#now-sure");
		layer.msg(a.errorMsg, {
			icon: 0,
			time: 2E3,
			offset: 300
		})
	}
	function k(a) {
		next("five-bind", "unpassbind");
		fresh_pages();
		clearForm()
	}
	$("body").find("#bind-mobile-form").validate({
		submitHandler: function(a) {
			a = $(a).serialize();
			cancelBtn("#now-sure");
			doRequest("/user/bind_mobile.html", a, !1, b, d)
		},
		rules: {
			uMobile: {
				isMobile: !0,
				remote: {
					type: "POST",
					url: "/site/checkMobile.html"
				}
			},
			smsCode: {
				smscode: !0,
				remote: {
					type: "POST",
					url: "/site/checkSmsCode.html"
				}
			},
			chkCapcha: {
				authcode: !0,
				remote: {
					type: "POST",
					url: "/site/checkCapcha.html"
				}
			}
		},
		messages: {
			uMobile: {
				required: "\u8bf7\u8f93\u5165\u65b0\u624b\u673a\u53f7\u7801",
				remote: "\u624b\u673a\u53f7\u5df2\u88ab\u5360\u7528"
			},
			smsCode: {
				required: "\u8bf7\u8f93\u5165\u77ed\u4fe1\u9a8c\u8bc1\u7801",
				remote: "\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef"
			},
			chkCapcha: {
				required: "\u8bf7\u8f93\u5165\u56fe\u7247\u9a8c\u8bc1\u7801",
				remote: "\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef"
			}
		},
		errorPlacement: function(a, c) {
			a.appendTo(c.parent());
			a.addClass("error");
			"mobile_box" == a.parent().attr("id") && $("#sendMobilebtn").css("cursor", "not-allowed").attr("disabled", "true").addClass("bg-dc").removeClass("bg-red")
		},
		success: function(a) {
			"mobile_box" == a.parent().attr("id") && $("#sendMobilebtn").css("cursor", "pointer").removeAttr("disabled").addClass("bg-red").removeClass("bg-dc");
			a.remove()
		}
	});
	$("body").find("#modify-mobile-form").validate({
		submitHandler: function(a) {
			doRequest("/site/clear_sms_code.html", {
				time: Math.random()
			}, !0, function(a) {}, function(a) {});
			next("old", "unnow");
			$(".back-icon").attr("onclick", "next('unnow','old');")
		},
		rules: {
			smsCode: {
				smscode: !0,
				remote: {
					type: "POST",
					url: "/site/checkSmsCode.html"
				}
			}
		},
		messages: {
			smsCode: {
				required: "\u8bf7\u8f93\u5165\u77ed\u4fe1\u9a8c\u8bc1\u7801",
				remote: "\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef"
			}
		},
		errorPlacement: function(a, c) {
			a.appendTo(c.parent());
			a.addClass("error")
		},
		success: function(a) {
			a.remove()
		}
	});
	$("body").find("#bind-email-form").validate({
		submitHandler: function(a) {
			a = $(a).serialize();
			cancelBtn("#now-sure");
			doRequest("/user/bind_email.html", a, !1, g, h)
		},
		rules: {
			uEmail: {
				isEmail: !0,
				remote: {
					type: "POST",
					url: "/site/checkEmail.html"
				}
			},
			emailCode: {
				smscode: !0,
				remote: {
					type: "POST",
					url: "/site/checkEmailCode.html"
				}
			},
			chkCapcha: {
				authcode: !0,
				remote: {
					type: "POST",
					url: "/site/checkCapcha.html"
				}
			}
		},
		messages: {
			uEmail: {
				required: "\u8bf7\u8f93\u5165\u65b0\u90ae\u7bb1\u53f7\u7801",
				remote: "\u90ae\u7bb1\u5df2\u88ab\u5360\u7528"
			},
			emailCode: {
				required: "\u8bf7\u8f93\u5165\u90ae\u7bb1\u9a8c\u8bc1\u7801",
				remote: "\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef"
			},
			chkCapcha: {
				required: "\u8bf7\u8f93\u5165\u56fe\u7247\u9a8c\u8bc1\u7801",
				remote: "\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef"
			}
		},
		errorPlacement: function(a, c) {
			a.appendTo(c.parent());
			a.addClass("error");
			"email_box" == a.parent().attr("id") && $("#sendEmailbtn").css("cursor", "not-allowed").attr("disabled", "true").addClass("bg-dc").removeClass("bg-red")
		},
		success: function(a) {
			"email_box" == a.parent().attr("id") && $("#sendEmailbtn").css("cursor", "pointer").removeAttr("disabled").addClass("bg-red").removeClass("bg-dc");
			a.remove()
		}
	});
	$("body").find("#modify-email-form").validate({
		submitHandler: function(a) {
			doRequest("/site/clear_sms_code.html", {
				time: Math.random()
			}, !0, function(a) {}, function(a) {});
			next("oldmail", "nowmail");
			$(".back-icon").attr("onclick", "next('nowmail','oldmail');")
		},
		rules: {
			emailCode: {
				smscode: !0,
				remote: {
					type: "POST",
					url: "/site/checkEmailCode.html"
				}
			}
		},
		messages: {
			emailCode: {
				required: "\u8bf7\u8f93\u5165\u90ae\u7bb1\u9a8c\u8bc1\u7801",
				remote: "\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef"
			}
		},
		errorPlacement: function(a, c) {
			a.appendTo(c.parent());
			a.addClass("error")
		},
		success: function(a) {
			a.remove()
		}
	});
	$("body").find("#modify-paypass-form").validate({
		submitHandler: function(a) {
			a = $(a).serialize();
			doRequest("/user/set_paypass.html", a, !0, e, f)
		},
		rules: {
			payPass: {
				checkcode: !0
			},
			rePayPass: {
				equalTo: "#payPass"
			},
			smsCode: {
				smscode: !0,
				remote: {
					type: "POST",
					url: "/site/checkSmsCode.html"
				}
			}
		},
		messages: {
			payPass: {
				required: "\u8bf7\u8f93\u5165\u65b0\u4ea4\u6613\u5bc6\u7801"
			},
			rePayPass: {
				required: "\u8bf7\u518d\u6b21\u8f93\u5165\u60a8\u7684\u5bc6\u7801",
				equalTo: "\u5bc6\u7801\u4e0d\u4e00\u81f4\uff0c\u8bf7\u518d\u6b21\u786e\u8ba4"
			},
			smsCode: {
				required: "\u8bf7\u8f93\u5165\u77ed\u4fe1\u9a8c\u8bc1\u7801",
				remote: "\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef"
			}
		},
		errorPlacement: function(a, c) {
			a.appendTo(c.parent());
			a.addClass("error");
			"rePayPass" == c.attr("name") && $("#sendPayBtn").css("cursor", "not-allowed").attr("disabled", "true").addClass("bg-dc").removeClass("bg-red")
		},
		success: function(a) {
			"rePayPass" == a.attr("for") && $("#sendPayBtn").css("cursor", "pointer").removeAttr("disabled").addClass("bg-red").removeClass("bg-dc");
			a.remove()
		}
	});
	$("body").find("#modify-pass-form").validate({
		submitHandler: function(a) {
			a = $(a).serialize();
			doRequest("/user/set_loginpass.html", a, !0, k, f)
		},
		rules: {
			loginPass: "required",
			newLoginPass: {
				isPwd: !0
			},
			reLoginPass: {
				equalTo: "#newLoginPass"
			}
		},
		messages: {
			loginPass: {
				required: "\u8bf7\u8f93\u5165\u539f\u59cb\u767b\u5f55\u5bc6\u7801"
			},
			newLoginPass: {
				required: "\u8bf7\u8f93\u5165\u65b0\u767b\u5f55\u5bc6\u7801"
			},
			reLoginPass: {
				required: "\u8bf7\u518d\u6b21\u8f93\u5165\u65b0\u5bc6\u7801",
				equalTo: "\u5bc6\u7801\u4e0d\u4e00\u81f4\uff0c\u8bf7\u518d\u6b21\u786e\u8ba4"
			}
		},
		errorPlacement: function(a, c) {
			a.appendTo(c.parent());
			a.addClass("error")
		},
		success: function(a) {
			a.remove()
		}
	});
	$("body").find("#modify-info-form").validate({
		submitHandler: function(a) {
			a = $(a).serialize();
			doRequest("/user/set_bascinfo.html", a, !0, function() {
				next("six-bind", "unbaseinfo");
				fresh_pages();
				clearForm()
			}, f)
		},
		rules: {
			trueName: {
				isName: !0
			},
			nickName: "required",
			QQ: "required",
			sigNature: "required"
		},
		messages: {
			trueName: {
				required: "\u8bf7\u8f93\u5165\u771f\u5b9e\u59d3\u540d"
			},
			nickName: {
				required: "\u8bf7\u8f93\u5165\u6635\u79f0"
			},
			QQ: {
				required: "\u8bf7\u8f93\u5165QQ\u8054\u7cfb\u65b9\u5f0f"
			},
			sigNature: {
				required: "\u8bf7\u8f93\u5165\u4e2a\u6027\u7b7e\u540d"
			}
		},
		errorPlacement: function(a, c) {
			a.appendTo(c.parent());
			a.addClass("error")
		},
		success: function(a) {
			a.remove()
		}
	});
	$("body").find("#alipay-form").validate({
		submitHandler: function(a) {
			a = $(a).serialize();
			doRequest("/user/bind_alipay.html", a, !1, function(a) {
				clearForm();
				$("#alipay-list").html(a.data);
				clearTimeout(global_cfg.tt);
				layer.msg(a.errorMsg, {
					icon: 1,
					time: 2E3,
					offset: 300
				})
			}, errorCallback)
		},
		rules: {
			Name: {
				isName: !0
			},
			Account: {
				isAlipay: !0
			},
			reAccount: {
				equalTo: "#alipayAccount"
			},
			smsCode: {
				smscode: !0,
				remote: {
					type: "POST",
					url: "/site/checkSmsCode.html"
				}
			}
		},
		messages: {
			Name: {
				required: "\u8bf7\u8f93\u5165\u771f\u5b9e\u59d3\u540d"
			},
			Account: {
				required: "\u8bf7\u8f93\u5165\u652f\u4ed8\u5b9d\u8d26\u53f7"
			},
			reAccount: {
				required: "\u8bf7\u518d\u8f93\u5165\u4e00\u904d\u652f\u4ed8\u5b9d\u8d26\u53f7",
				equalTo: "\u8d26\u53f7\u4e0d\u4e00\u81f4\uff0c\u8bf7\u518d\u6b21\u786e\u8ba4"
			},
			smsCode: {
				required: "\u8bf7\u8f93\u5165\u77ed\u4fe1\u9a8c\u8bc1\u7801",
				remote: "\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef"
			}
		},
		errorPlacement: function(a, c) {
			"reAccount" == c.attr("name") && $("#send-alipay-btn").css("cursor", "not-allowed").attr("disabled", "true").css("background", "#dcdcdc");
			a.appendTo(c.parent());
			a.addClass("error")
		},
		success: function(a) {
			"reAccount" == $(a).attr("for") && $("#send-alipay-btn").css("cursor", "pointer").removeAttr("disabled").css("background", "#fd8686");
			a.remove()
		}
	});
	$("body").find("#bank-form").validate({
		submitHandler: function(a) {
			a = $(a).serialize();
			doRequest("/user/bind_bank.html", a, !1, function(a) {
				clearForm();
				clearTimeout(global_cfg.tt);
				$("#bank-list").html(a.data);
				layer.msg(a.errorMsg, {
					icon: 1,
					time: 2E3,
					offset: 300
				})
			}, errorCallback)
		},
		rules: {
			Name: {
				isName: !0
			},
			bankType: "required",
			bankHome: "required",
			Account: {
				isBank: !0
			},
			reAccount: {
				equalTo: "#bankAccount"
			},
			smsCode: {
				smscode: !0,
				remote: {
					type: "POST",
					url: "/site/checkSmsCode.html"
				}
			}
		},
		messages: {
			Name: {
				required: "\u8bf7\u8f93\u5165\u771f\u5b9e\u59d3\u540d"
			},
			bankType: {
				required: "\u8bf7\u9009\u62e9\u94f6\u884c\u7c7b\u578b"
			},
			bankHome: {
				required: "\u8bf7\u8f93\u5165\u94f6\u884c\u5f00\u6237\u884c"
			},
			Account: {
				required: "\u8bf7\u8f93\u5165\u652f\u4ed8\u5b9d\u8d26\u53f7"
			},
			reAccount: {
				required: "\u8bf7\u518d\u8f93\u5165\u4e00\u904d\u94f6\u884c\u5361\u8d26\u53f7",
				equalTo: "\u8d26\u53f7\u4e0d\u4e00\u81f4\uff0c\u8bf7\u518d\u6b21\u786e\u8ba4"
			},
			smsCode: {
				required: "\u8bf7\u8f93\u5165\u77ed\u4fe1\u9a8c\u8bc1\u7801",
				remote: "\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef"
			}
		},
		errorPlacement: function(a, c) {
			"reAccount" == c.attr("name") && $("#send-bank-btn").css("cursor", "not-allowed").attr("disabled", "true").css("background", "#dcdcdc");
			a.appendTo(c.parent());
			a.addClass("error")
		},
		success: function(a) {
			"reAccount" == $(a).attr("for") && $("#send-bank-btn").css("cursor", "pointer").removeAttr("disabled").css("background", "#fd8686");
			a.remove()
		}
	});
	$("body").find("#cash-withdraw-form").validate({
		submitHandler: function(a) {
			var c = $(a).parents(".cash-list").find(".card-border"),
				b = {},
				d = a.cashAmount.value,
			t = a.cashPaypass.value;
			var c = c.attr("data-type"),
				e = $(a).parents(".cash-list").find("#cash-withdraw-btn").attr("data-key"),
				f = "",
				f = 1 == c ? $(a).parents(".cash-list").find("input[name='alipay[]']:checked").val() : $(a).parents(".cash-list").find("input[name='bank[]']:checked").val();
			b.accountId = f;
			b.payPass = t;
			b.cashValue = d;
			b.type = c;
			b.keyCode = e;
			doRequest("/user/do_cash.html", b, !1, function(a) {
				clearForm();
				layer.alert("\u60a8\u7684\u63d0\u73b0\u7533\u8bf7\u5df2\u7ecf\u63d0\u4ea4\uff0c\u8bf7\u8010\u5fc3\u7b49\u5f85\u4e24\u4e2a\u5de5\u4f5c\u65e5", {
					title: "\u5c0f6\u63d0\u793a",
					btn: ["\u786e\u8ba4"],
					offset: 300,
					icon: 1
				}, function() {
					window.location.href = "/user/trade_records.html"
				})
			}, errorCallback)
		},
		rules: {
			cashAmount: {
				isAmount: !0
			},
			cashPaypass: "required"
		},
		messages: {
			cashAmount: {
				required: "\u8bf7\u8f93\u5165\u6709\u6548\u7684\u63d0\u73b0\u91d1\u989d"
			},
			cashPaypass: {
				required: "\u4ea4\u6613\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a"
			}
		},
		errorPlacement: function(a, b) {
			a.appendTo(b.parent());
			a.addClass("error")
		},
		success: function(a) {
			a.remove()
		}
	});
        
        $("body").find("#liuzhu-withdraw-form").validate({
	submitHandler: function(a) {
		var b = $(a).parents(".cash-list").find(".card-border"),
			c = {},
			e = a.cashAmount.value,
			f = a.cashPaypass.value,
			b = b.attr("data-type"),
			g = $(a).parents(".cash-list").find("#cash-withdraw-btn").attr("data-key"),
			d = "",
			d = 1 == b ? $(a).parents(".cash-list").find("input[name='alipay[]']:checked").val() : $(a).parents(".cash-list").find("input[name='bank[]']:checked").val();
		c.accountId = d;
		c.payPass = f;
		c.cashValue = e;
		c.type = b;
		c.keyCode = g;
		doRequest("/user/do_lzcash.html", c, !1, function(a) {
			clearForm();
			layer.alert("\u60a8\u7684\u63d0\u73b0\u7533\u8bf7\u5df2\u7ecf\u63d0\u4ea4\uff0c\u8bf7\u8010\u5fc3\u7b49\u5f85\u4e24\u4e2a\u5de5\u4f5c\u65e5", {
				title: "\u5c0f6\u63d0\u793a",
				btn: ["\u786e\u8ba4"],
				offset: 300,
				icon: 1
			}, function() {
				window.location.href = "/user/trade_records.html"
			})
		}, errorCallback)
	},
	rules: {
		cashAmount: {
			isAmount: !0
		},
		cashPaypass: "required"
	},
	messages: {
		cashAmount: {
			required: "\u8bf7\u8f93\u5165\u6709\u6548\u7684\u63d0\u73b0\u91d1\u989d"
		},
		cashPaypass: {
			required: "\u4ea4\u6613\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a"
		}
	},
	errorPlacement: function(a, b) {
		a.appendTo(b.parent());
		a.addClass("error")
	},
	success: function(a) {
		a.remove()
	}
    });
        
	$("body").find("#modify-address-form").validate({
		submitHandler: function(a) {
			a = $(a).serialize();
			doRequest("/user/set_address.html", a, !1, function() {
				next("show-add", "unadress");
				fresh_pages();
				clearForm()
			}, f)
		},
		rules: {
			receiverName: {
				isName: !0
			},
			receiverMobile: {
				isMobile: !0
			},
			receiverPrivince: "required",
			receiverCity: "required",
			receiverAddress: "required"
		},
		messages: {
			receiverName: {
				required: "\u59d3\u540d\u4e0d\u80fd\u4e3a\u7a7a"
			},
			receiverMobile: {
				required: "\u624b\u673a\u53f7\u4e0d\u80fd\u4e3a\u7a7a"
			},
			receiverPrivince: {
				required: "\u6240\u5c5e\u7701\u4efd\u4e0d\u80fd\u4e3a\u7a7a"
			},
			receiverCity: {
				required: "\u6240\u5c5e\u57ce\u5e02\u4e0d\u80fd\u4e3a\u7a7a"
			},
			receiverAddress: {
				required: "\u6240\u5c5e\u8be6\u7ec6\u8857\u9053\u4e0d\u80fd\u4e3a\u7a7a"
			}
		},
		errorPlacement: function(a, b) {
			a.appendTo(b.parent());
			a.addClass("error")
		},
		success: function(a) {
			a.remove()
		}
	});
	$("body").delegate(".delete-bind a", "click", function() {
		var a = {},
			b = $(this).attr("data-id"),
			d = $(this).attr("data-type");
		a.id = b;
		a.type = d;
		layer.confirm("\u771f\u7684\u5fcd\u5fc3\u5220\u9664\u5417\uff1f", {
			title: "\u5c0f6\u63d0\u793a",
			offset: 300,
			icon: 5,
			btn: ["\u5fcd\u5fc3", "\u518d\u60f3\u60f3"]
		}, function() {
			doRequest("/user/bind_del.html", a, !1, function(a) {
				1 == d ? $("#alipay-list").html(a.data) : $("#bank-list").html(a.data);
				layer.msg(a.errorMsg, {
					icon: 1,
					time: 2E3,
					offset: 300
				})
			}, errorCallback)
		}, function() {})
	})
});

function del_address(b) {
	$(b);
	b = $(b).attr("data-id");
	var d = {};
	d.id = b;
	doRequest("/user/set_address_del.html", d, !1, function() {
		layer.msg("\u6210\u529f\u5220\u9664", {
			icon: 1,
			offset: 300,
			time: 2E3
		}, function() {
			window.location.reload()
		})
	}, errorCallback)
}
function def_address(b) {
	$(b);
	var d = $(b).attr("data-id"),
		e = {};
	1 == $(b).attr("data-status") ? layer.msg("\u5df2\u662f\u9ed8\u8ba4\u72b6\u6001", {
		icon: 0,
		offset: 300,
		time: 2E3
	}) : (e.id = d, doRequest("/user/set_address_default.html", e, !1, function() {
		layer.msg("\u8bbe\u7f6e\u6210\u529f", {
			icon: 1,
			offset: 300,
			time: 2E3
		}, function() {
			window.location.reload()
		})
	}, errorCallback))
}
function show(b) {
	b = document.getElementById(b);
	"block" == b.style.display ? b.style.display = "none" : "none" == b.style.display && (b.style.display = "block")
}
function next(b, d) {
	$("#" + b + "").hide();
	$("#" + d + "").show()
}
function fresh_pages() {
	for (i = 1; 3 >= i; i++) window.setTimeout("do_fresh_pages(" + i + ",3)", 1E3 * i)
}
function do_fresh_pages(b, d) {
	if (b == d) window.location.href = "/user/security.html";
	else {
		var e = d - b;
		$(".fresh-pages").html("" + e + "s\u540e\u81ea\u52a8\u5237\u65b0\u9875\u9762")
	}
}
$(function() {
	$(".bg-red").click(function() {
		var b = $(this);
		b.addClass("bg-dc");
		b.removeClass("bg-red")
	});
	$(".vip-btn").click(function() {
		var b = $(this).attr("data-flag"),
			d = $(this).attr("data-next-degree");
		if (0 == b) return layer.msg("\u60a8\u8fd8\u672a\u8fbe\u5230\u5347\u7ea7<span style='color:#F4772B;font-size:16px;'>VIP" + d + "</span>\u7684\u6761\u4ef6\u54e6", {
			icon: 0,
			time: 3E3,
			offset: 300
		}), !1;
		doRequest("/user/do_vip.html", {
			stime: Math.random()
		}, !1, function(b) {
			1E3 == b.errorCode ? layer.msg(b.errorMsg, {
				icon: 0,
				time: 3E3,
				offset: 300
			}) : ($(".popup-box").children().find("i.exper-s").html(b.exper_award), $(".popup-box").children().find("i.sign-s").html(b.sign_award), $(".popup-box").children("p").html("Lv" + d), $(".popup-box").fadeIn(100))
		}, errorCallback)
	})
});